package com.haiyou.common.exception;

import com.haiyou.common.constant.MessageCode;

/**
 * @author chenzeke
 * @date 2019/4/30 10:38
 * @description 全局业务异常类
 */
public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    private String message;
    private int code;

    public BusinessException(MessageCode messageCode) {
        super(messageCode.getMessage());
        this.message = messageCode.getMessage();
        this.code = messageCode.getCode();
    }

    public BusinessException(String message) {
        super(message);
        this.message = message;
    }

    public BusinessException(String message, Throwable e) {
        super(message, e);
        this.message = message;
    }

    public BusinessException(String message, int code) {
        super(message);
        this.message = message;
        this.code = code;
    }

    public BusinessException(String message, int code, Throwable e) {
        super(message, e);
        this.message = message;
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
